package com.aspose.cells;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;

abstract class zgd {
   protected static float a = com.aspose.cells.a.d.zfq.a();
   static float b = 0.67F;
   protected float c = 0.0F;
   protected float d = 0.0F;
   float e = 0.0F;
   float f = 0.0F;
   protected int g;
   protected int h;
   ArrayList i;
   protected boolean j = false;
   com.aspose.cells.a.d.ze k;
   protected boolean l = false;
   protected zga m;
   protected float n;
   protected boolean[] o = new boolean[]{false};
   private static com.aspose.cells.b.a.g.a.ze p = new com.aspose.cells.b.a.g.a.ze("([\\u0600-\\u06ff\\u0590-\\u05FF]+)|([^\\u0600-\\u06ff\\u0590-\\u05FF]+)|([\\w]+)");
   private static com.aspose.cells.b.a.g.a.ze q = new com.aspose.cells.b.a.g.a.ze("(\\s+)|([\\u2E80-\\u9FFF\\uF900-\\uFAFF\\uFF00-\\uFFEF])|([^\\u2E80-\\u9FFF\\uF900-\\uFAFF\\uFF00-\\uFFEF\\s]+)");
   private static com.aspose.cells.b.a.g.a.ze r = new com.aspose.cells.b.a.g.a.ze("(\\n+)|([a-zA-Z]+)|([\\u0000-\\u007F-[a-zA-Z\\n]]+)|([\\uFB50-\\uFDFF\\uFE70-\\uFEFF\\u0590-\\u05FF]+)|([\\u0080-\\uFFFF-[\\uFB50-\\uFDFF\\uFE70-\\uFEFF\\u0590-\\u05FF]]+)");
   private static com.aspose.cells.b.a.g.a.ze s = new com.aspose.cells.b.a.g.a.ze("([\\uF020-\\uF0FF]+)|([^\\uF020-\\uF0FF]+)");

   protected zgd(ArrayList var1, zga var2, float var3, float var4, float var5, double[] var6, boolean var7) throws Exception {
      this.n = var5;
      this.m = var2;
      this.i = new ArrayList();
      this.c = var3;
      this.d = var4;
      this.b(var2);
      this.a(var2);
      this.j = var7;
      this.l = var2.a;

      for(int var8 = 0; var8 < var1.size(); ++var8) {
         zot var9 = (zot)var1.get(var8);
         if (var9 != null && var9.a != null && var9.a.length() != 0) {
            var9.a = var9.a.replace('\r', ' ');
            int var10 = var9.a.indexOf(10);
            if (var10 >= 0) {
               zot var11 = new zot();
               var11.b = var9.b;
               var11.a = var9.a.substring(0, 0 + var10);
               var9.a = var9.a.substring(var10 + 1);
               zot var12 = new zot();
               var12.b = var9.b;
               var12.a = "";
               var12.d = 16;
               var1.add(var8, var12);
               var1.add(var8, var11);
            }
         }
      }

      this.a(var1, var6);

      zamb var14;
      for(Iterator var13 = this.i.iterator(); var13.hasNext(); this.f += var14.d) {
         var14 = (zamb)var13.next();
         if (this.e < var14.c) {
            this.e = var14.c;
         }
      }

      this.c(var2);
   }

   private void a(zga var1) {
      this.g = var1.c().getVerticalAlignment();
      if (var1.c().getRotationAngle() <= 0 && var1.c().getRotationAngle() < 0) {
         ;
      }

      if (var1.c().getRotationAngle() == 0) {
         this.g = var1.c().getVerticalAlignment();
      }

   }

   private void b(zga var1) {
      this.h = var1.g();
      if (var1.c().getRotationAngle() > 0) {
         switch(var1.c().getVerticalAlignment()) {
         case 0:
            this.h = 7;
            break;
         case 9:
            this.h = 8;
            break;
         default:
            this.h = var1.c().getVerticalAlignment();
         }
      } else if (var1.c().getRotationAngle() < 0) {
         switch(var1.c().getVerticalAlignment()) {
         case 0:
            this.h = 8;
            break;
         case 9:
            this.h = 7;
            break;
         default:
            this.h = var1.c().getVerticalAlignment();
         }
      } else {
         switch(this.h) {
         case 4:
            this.h = 7;
            break;
         case 6:
            this.h = 6;
         }
      }

   }

   private void c(zga var1) {
      float var2 = 0.0F;
      float var3 = 0.0F;
      float var4 = 0.0F;
      this.e += var1.a();
      if (this.g == 3) {
         float var5 = this.d / a * 72.0F;
         if (this.i.size() > 1) {
            var4 = (var5 - this.f - 2.0F) / (float)(this.i.size() - 1);
         } else if (this.i.size() == 1) {
            var2 += (var5 - this.f - 2.0F) / 2.0F;
         }

         this.f = var5;
      }

      var3 = var2;

      for(int var7 = this.i.size() - 1; var7 >= 0; --var7) {
         zamb var6 = (zamb)this.i.get(var7);
         var6.b -= var3;
         var3 += var6.d + var4;
         switch(this.h) {
         case 1:
         case 2:
            var6.e = (this.e - var6.c) / 2.0F;
            break;
         case 3:
            var6.e = 1.0F;
            this.e = this.c / a * 72.0F;
            if (var6.a.size() >= 2) {
               var6.h = (this.e - 2.0F - var6.c) / (float)(var6.a.size() - 1);
            } else if (var6.a.size() == 1) {
               var6.e = (this.e - var6.c) / 2.0F;
            }

            if (var6.h < 0.0F) {
               var6.h = 0.0F;
            }
         case 4:
         case 5:
         default:
            break;
         case 6:
            var6.e = 1.0F;
            this.e = this.c / a * 72.0F;
            if (var6.a.size() >= 2 && !var6.i) {
               var6.h = (this.e - 2.0F - var6.c) / (float)(var6.a.size() - 1);
            }

            if (var6.h >= 0.0F && var7 == this.i.size() - 1) {
               var6.h = 0.0F;
            }
            break;
         case 7:
            var6.e = 1.0F + var1.a();
            break;
         case 8:
            if (this.l) {
               var6.e = 1.0F;
            } else {
               var6.e = this.e - var6.c - 1.0F - var1.a();
            }
         }
      }

   }

   protected abstract void a(ArrayList var1, double[] var2) throws Exception;

   abstract void a(com.aspose.cells.a.d.zb var1) throws Exception;

   static float a(double var0, float var2) {
      int var3 = (int)(var0 * (double)var2 * 100.0D);
      int var4 = var3 % 12;
      return var4 < 6 ? (float)(var3 - var4) / 100.0F : (float)(var3 + 12 - var4) / 100.0F;
   }

   static float b(double var0, float var2) {
      return (float)(var0 * (double)var2);
   }

   static void a(String var0, boolean var1, int var2, zakl var3) {
      int var4 = var0.length();
      if (var4 >= 1) {
         int var5 = 0;
         int var6 = 0;

         while(var5 < var4) {
            com.aspose.cells.b.a.g.a.zc var7;
            if (var1) {
               var7 = r.a(var0, var5);
            } else {
               var7 = q.a(var0, var5);
            }

            if (!var7.c()) {
               break;
            }

            var5 += var7.e();
            if (var5 == var4) {
               if (var6 > 0 && var7.b().a(1).a()) {
                  var3.b();
               }
               break;
            }

            if (var7.b().a(1).a()) {
               if (var6 < 1) {
                  var3.a(var5);
                  ++var6;
               }
            } else {
               var3.a(var5);
               ++var6;
               if (var2 > 0 && var6 >= var2) {
                  break;
               }
            }
         }

      }
   }

   static void a(ArrayList var0) {
      ArrayList var1 = new ArrayList();

      for(int var2 = 0; var2 < var0.size(); ++var2) {
         zot var3 = (zot)var0.get(var2);
         if (var3.d == 1) {
            com.aspose.cells.b.a.a.ze.a(var1, (Object)var3);
         } else {
            for(int var4 = 0; var4 < var3.a.length(); ++var4) {
               char var5 = var3.a.charAt(var4);
               zot var6 = new zot();
               var6.a = "" + var5;
               var6.b = var3.b;
               var6.d = var3.d;
               com.aspose.cells.b.a.a.ze.a(var1, (Object)var6);
            }
         }
      }

      var0.clear();
      com.aspose.cells.b.a.a.ze.a(var0, (Collection)var1);
   }

   static void a(ArrayList var0, boolean var1) {
      ArrayList var2 = new ArrayList();

      for(int var3 = 0; var3 < var0.size(); ++var3) {
         ArrayList var4 = new ArrayList();
         zot var5 = (zot)var0.get(var3);
         Font var6 = var5.b;
         int var7 = var5.a.length();

         com.aspose.cells.b.a.g.a.zc var9;
         for(int var8 = 0; var8 < var7; var8 += var9.e()) {
            if (var1) {
               var9 = r.a(var5.a, var8);
            } else {
               var9 = q.a(var5.a, var8);
            }

            if (!var9.c()) {
               break;
            }

            zot var10 = new zot();
            var10.a = var9.a();
            var10.b = var6;
            var10.d = var5.d;
            com.aspose.cells.b.a.a.ze.a(var4, (Object)var10);
         }

         if (var1) {
            Collections.reverse(var4);
         }

         com.aspose.cells.b.a.a.ze.a(var2, (Collection)var4);
      }

      var0.clear();
      com.aspose.cells.b.a.a.ze.a(var0, (Collection)var2);
   }

   static ArrayList a(String var0) {
      ArrayList var1 = new ArrayList();
      int var2 = var0.length();

      com.aspose.cells.b.a.g.a.zc var4;
      for(int var3 = 0; var3 < var2; var3 += var4.e()) {
         var4 = s.a(var0, var3);
         if (!var4.c()) {
            break;
         }

         com.aspose.cells.b.a.a.ze.a(var1, (Object)var4.a());
      }

      return var1;
   }
}
